class Series < Event
  has_many :events
  validates_presence_of :name
  validates_presence_of :place
  validates_presence_of :start_time
  validate :series_is_not_in_the_past
  validate :series_ends_after_it_starts
  
  def series_is_not_in_the_past
    return if self.start_time.nil?
    self.errors.add(:start_time,'can not be in the past') if self.start_time <= Time.now
  end  
  
  def series_ends_after_it_starts
    return if self.end_time.nil?
    self.errors.add(:end_time,'must be after start date') if self.end_time <= self.start_time
  end
    	
end

  

